
package com.insigma.business.qrcode.common.converter;


import com.insigma.business.qrcode.soldier.dto.SoldierApplyInfoBSearcher;
import com.insigma.business.qrcode.soldier.dto.SoldierApplyInfoDTO;
import com.insigma.business.qrcode.soldier.dto.SoldierApplyInfoInsertRequest;
import com.insigma.business.qrcode.soldier.dto.SoldierApplyInfoUpdateRequest;
import com.insigma.business.qrcode.soldier.entity.SoldierApplyInfoDO;
import com.insigma.business.qrcode.soldier.request.SoldierApplyInfoSearchRequest;
import com.insigma.business.qrcode.common.converter.AbstractConverter;
import org.springframework.beans.BeanUtils;

import java.util.List;


public class SoldierApplyInfoProviderConverter extends AbstractConverter<SoldierApplyInfoDTO, SoldierApplyInfoDO> {

    private final static SoldierApplyInfoProviderConverter soldierApplyInfoConverter = new SoldierApplyInfoProviderConverter();

    private SoldierApplyInfoProviderConverter(){}

    
    public static SoldierApplyInfoBSearcher convertRequestSO2Searcher(final SoldierApplyInfoSearchRequest request){
        final SoldierApplyInfoBSearcher soldierApplyInfoBSearcher = new SoldierApplyInfoBSearcher(request.getPageNo(),
        request.getPageSize(),request.getSortKeyValueJoint());
        BeanUtils.copyProperties(request,soldierApplyInfoBSearcher);
        return soldierApplyInfoBSearcher;
    }

    
    public static SoldierApplyInfoDO convertRequestUO2DO(final SoldierApplyInfoUpdateRequest soldierApplyInfoUpdateRequest) {
        final SoldierApplyInfoDO soldierApplyInfoDO = new SoldierApplyInfoDO();
        BeanUtils.copyProperties(soldierApplyInfoUpdateRequest,soldierApplyInfoDO);
        
        return soldierApplyInfoDO;
    }

    
    public static SoldierApplyInfoDO convertRequestIO2DO(final SoldierApplyInfoInsertRequest soldierApplyInfoInsertRequest) {
        final SoldierApplyInfoDO soldierApplyInfoDO = new SoldierApplyInfoDO();
        BeanUtils.copyProperties(soldierApplyInfoInsertRequest,soldierApplyInfoDO);
        return soldierApplyInfoDO;
    }

    
    public static List<SoldierApplyInfoDTO> convertResponseDOList2DTOList(final List<SoldierApplyInfoDO> soldierApplyInfoDOList){
        return soldierApplyInfoConverter.convertGenericResponseDOList2DTOList(soldierApplyInfoDOList);
    }

    
    public static SoldierApplyInfoDTO convertResponseDO2DTO(final SoldierApplyInfoDO soldierApplyInfoDO){
        return soldierApplyInfoConverter.convertGenericResponseDO2DTO(soldierApplyInfoDO);
    }

    
    @Override
    protected SoldierApplyInfoDTO doConvertResponseDO2DTO(SoldierApplyInfoDO soldierApplyInfoDO) {
        final SoldierApplyInfoDTO soldierApplyInfoDTO = new SoldierApplyInfoDTO();
        try {
            BeanUtils.copyProperties(soldierApplyInfoDO, soldierApplyInfoDTO);
        }catch(RuntimeException be){
            
            return null;
        }
        return soldierApplyInfoDTO;
    }

}
